﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;

namespace Public
{
    public class WebSession 
    {
        
        /// <summary>
        /// 管理员ID
        /// </summary>
        public static int AdminID
        {
            get
            {
                if (HttpContext.Current.Session["AdminID"] == null)
                {
                    // Session过期处理.
                    return 0;
                }
                else
                    return Convert.ToInt32(HttpContext.Current.Session["AdminID"]);
            }
            set
            {
                HttpContext.Current.Session["AdminID"] = value;
            }
        }

        /// <summary>
        /// 管理员登录名
        /// </summary>
        public static string AdminLoginName
        {
            get
            {
                if (HttpContext.Current.Session["AdminLoginName"] == null)
                {
                    // Session过期处理.
                    return "";
                }
                else
                    return HttpContext.Current.Session["AdminLoginName"].ToString();
            }
            set
            {
                HttpContext.Current.Session["AdminLoginName"] = value;
            }
        }

        /// <summary>
        /// 管理员姓名
        /// </summary>
        public static string AdminFullName
        {
            get
            {
                if (HttpContext.Current.Session["AdminFullName"] == null)
                {
                    // Session过期处理.
                    return "";
                }
                else
                    return HttpContext.Current.Session["AdminFullName"].ToString();
            }
            set
            {
                HttpContext.Current.Session["AdminFullName"] = value;
            }
        }

        /// <summary>
        /// 空间地址
        /// </summary>
        public static string HomeSite
        {
            get
            {
                if (HttpContext.Current.Session["HomeSite"] == null)
                {
                    // Session过期处理.
                    return "";
                }
                else
                    return HttpContext.Current.Session["HomeSite"].ToString();
            }
            set
            {
                HttpContext.Current.Session["HomeSite"] = value;
            }
        }

        /// <summary>
        /// 管理员姓名
        /// </summary>
        public static bool IsAuthorized
        {
            get
            {
                if (HttpContext.Current.Session["IsAuthorized"] == null)
                {
                    // Session过期处理.
                    return false;
                }
                else
                    return (bool)HttpContext.Current.Session["IsAuthorized"];
            }
            set
            {
                HttpContext.Current.Session["IsAuthorized"] = true;
            }
        }


        /// <summary>
        /// 后台注销
        /// </summary>
        public static void AdminLogOut()
        {
            HttpContext.Current.Session["AdminID"] = null;
            HttpContext.Current.Session["AdminLoginName"] = null;
            HttpContext.Current.Session["AdminFullName"] = null;
            HttpContext.Current.Session["IsAuthorized"] = null;
        }
    }
}
